package com.liupei;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassNameOauth2Application
 * @Description
 * @Author liupei
 * @Emaile 3268727800@qq.com
 * @Date2021/3/12 17:10
 * @Version V1.0
 **/
@SpringBootApplication
@EnableAuthorizationServer
@EnableEurekaClient
//@MapperScan("com.liupei.*.*.mapper")
@EnableFeignClients
@PropertySource(value = {"classpath:oauth.properties"},encoding = "UTF-8")
public class Oauth2Application extends SpringBootServletInitializer {
    protected static final Logger log = LoggerFactory.getLogger(Oauth2Application.class);

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return super.configure(builder);
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Oauth2Application.class, args);
        ConfigurableEnvironment env = context.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}" +
                        "\n----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"));
        log.info("OauthApplication 启动成功.....");
    }

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.build();
    }


}
